package com.cskaoyan.market.controller;

import com.cskaoyan.market.db.domain.MarketAdmin;
import com.cskaoyan.market.service.WxAuthService;
import com.cskaoyan.market.service.WxUserService;
import com.cskaoyan.market.util.AdminResponseCode;
import com.cskaoyan.market.util.ResponseUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.mgt.SecurityManager;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("wx/user")
public class WxUserController {

    @Autowired
    WxUserService wxUserService;


    @GetMapping("index")
    public Object index(HttpSession session){

        Integer id = (Integer) session.getAttribute("id");

        if (id == null){
            return null;
        }

        Map<String,Object> result = new HashMap<>();
        Map<String, Object> order = wxUserService.index(id);

        result.put("order",order);
        return ResponseUtil.ok(result);
    }
}
